package com.alan.entity;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class RestBean<T> {

    private int status;
    private T massage;
    private boolean success;



    //做成工具类
    private RestBean(int status, T massage, boolean success) {
        this.status = status;
        this.massage = massage;
        this.success = success;
    }

    public static <T> RestBean<T> success(){
        return new RestBean<>(200,null,true);
    }

    public static <T> RestBean<T> success(T data){
        return new RestBean<>(200,data,true);
    }

    public static <T> RestBean<T> success(int status){
        return new RestBean<>(status,null,true);
    }

    public static <T> RestBean<T> success(int status,T data){
        return new RestBean<>(status,data,true);
    }


    public static <T> RestBean<T> failure(){
        return new RestBean<>(200,null,false);
    }

    public static <T> RestBean<T> failure(T data){
        return new RestBean<>(400,data,false);
    }

    public static <T> RestBean<T> failure(int status){
        return new RestBean<>(status,null,false);
    }

    public static <T> RestBean<T> failure(int status,T data){
        return new RestBean<>(status,data,false);
    }

}
